import yaml

file = r'../demo-file/demo-yaml.yaml'

with open(file, 'r', encoding='utf-8') as f:
    load = f.read()

# 将yaml文件转化为python对象
load = yaml.safe_load(load)
print(load)

# 将python对象转化为yaml
dump = yaml.safe_dump(load)
print(dump)

load1 = yaml.safe_load_all(load)
print(load1)
data = list(yaml.safe_load_all(load1))